//
//  ConnectingView.m
//  NemoSDKDemo
//
//  Created by 高超 on 2020/8/10.
//  Copyright © 2020 JackYang. All rights reserved.
//

#import "ConnectingView.h"

@implementation ConnectingView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];

        self.avatarImgView = [[UIImageView alloc] initWithFrame:CGRectMake(20, UIApplication.sharedApplication.statusBarFrame.size.height + 44, 80, 80)];
        self.avatarImgView.image = [UIImage imageNamed:@"xylink_avator_image"];
        self.avatarImgView.layer.cornerRadius = 6.f;
        self.avatarImgView.layer.masksToBounds = YES;
        [self addSubview:self.avatarImgView];

        self.displayNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.avatarImgView.frame)+15, CGRectGetMinY(self.avatarImgView.frame)+15, kScreen.width-100-30, 20)];
        self.displayNameLabel.textColor = [UIColor whiteColor];
        self.displayNameLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
        self.displayNameLabel.textAlignment = NSTextAlignmentLeft;
        [self addSubview:self.displayNameLabel];

        self.statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.avatarImgView.frame)+15, CGRectGetMaxY(self.displayNameLabel.frame)+6, kScreen.width-100-30, 15)];
        self.statusLabel.textColor = [UIColor whiteColor];
        self.statusLabel.text = @"正在等待对方接受邀请···";
        self.statusLabel.font = [UIFont systemFontOfSize:14];
        self.statusLabel.textAlignment = NSTextAlignmentLeft;
        [self addSubview:self.statusLabel];
        
        self.hangupBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        self.hangupBtn.frame = CGRectMake((kScreen.width-62)/2, kScreen.height-107-UIApplication.sharedApplication.keyWindow.safeAreaInsets.bottom, 62, 87);
        [self.hangupBtn setImage:[UIImage imageNamed:@"xylink_reject_icon"] forState:UIControlStateNormal];
        [self.hangupBtn setTitle:@"挂断" forState:UIControlStateNormal];
        self.hangupBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        self.hangupBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
        self.hangupBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        self.hangupBtn.titleEdgeInsets = UIEdgeInsetsMake(70, -48, 0, 0);
        [self.hangupBtn addTarget:self action:@selector(hangup:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.hangupBtn];

    }
    return self;
}

- (void)hangup:(UIButton *)sender {
    if (self.hangup) {
        self.hangup();
    }
}

@end
